class Solution {
public:
    int findJudge(int n, vector<vector<int>>& trust) {
        vector<int> a(n+1,0);
        vector<bool> b(n+1,false);
        for(auto  &t:trust){
            a[t[1]]++;
            b[t[0]]= true;
        }
        for(int i=1;i<=n;i++)
            if(a[i]==n-1&&b[i]==false) return i;
        return -1;
    }
};